package com.inspinia.upms.common.model;

import com.inspinia.base.common.model.NameCodeEnum;

/**
 * shiro 对单点登录验证类型，默认是cookie认证
 */
public enum AuthType implements NameCodeEnum {

    cookie(1,"cookie"),
    token(2,"token"),
    oauth(3,"oauth");

    private final int code;
    private final String name;

    AuthType(int code, String name){
        this.code=code;
        this.name=name;
    }

    @Override
    public int getCode() {
        return code;
    }

    @Override
    public String getName() {
        return name;
    }

    public static AuthType valueOf(int code) {
        for (AuthType type : values()) {
            if (type.code == code) {
                return type;
            }
        }
        return null;
    }

    public static AuthType nameOf(String name){
        for (AuthType type : values()) {
            if (type.name.equals(name)) {
                return type;
            }
        }
        return null;
    }
}
